package com.software.levelupandroid.systemTask.view.activity;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.software.levelupandroid.R;

public class FirstSelectionActivity extends AppCompatActivity {
    private Toolbar toolbar;
    private Button studyButton, runButton, emotionButton, liveButton;
    private TextView nameText;
    private ImageView headImg;
    private FirstListener firstListener;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first_selection);


        findViews();
        toolbar = findViewById(R.id.toolbar_first);
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null)
            actionBar.setDisplayShowTitleEnabled(false);

        //TODO 传输昵称和头像

        setListener();
    }

    private void setListener() {
        firstListener = new FirstListener();
        studyButton.setOnClickListener(firstListener);
        runButton.setOnClickListener(firstListener);
        emotionButton.setOnClickListener(firstListener);
        liveButton.setOnClickListener(firstListener);
    }

    private void findViews() {
        studyButton = findViewById(R.id.first_select_study);
        runButton = findViewById(R.id.first_select_run);
        emotionButton = findViewById(R.id.first_select_emotion);
        liveButton = findViewById(R.id.first_select_live);
        nameText = findViewById(R.id.first_select_name);
        headImg = findViewById(R.id.first_select_head);
    }

    class FirstListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            Intent intent;
            switch (v.getId()) {
                case R.id.first_select_study:
                    intent = new Intent(FirstSelectionActivity.this, SecondSelectionActivity.class);
                    intent.putExtra("type", "1");
                    startActivity(intent);
                    break;
                case R.id.first_select_run:
                    intent = new Intent(FirstSelectionActivity.this, SecondSelectionActivity.class);
                    intent.putExtra("type", "3");
                    startActivity(intent);
                    break;
                case R.id.first_select_emotion:
                    intent = new Intent(FirstSelectionActivity.this, SecondSelectionActivity.class);
                    intent.putExtra("type", "4");
                    startActivity(intent);
                    break;
                case R.id.first_select_live:
                    intent = new Intent(FirstSelectionActivity.this, SecondSelectionActivity.class);
                    intent.putExtra("type", "2");
                    startActivity(intent);
                    break;

                default:
                    break;
            }
        }
    }

    @Override
    public boolean onSupportNavigateUp() {
        finish();
        return true;
    }
}